<?xml version="1.0" encoding="utf-8"?>
<Content xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="urn:blueonionsoftware-com:bloget:runtime:data">
  <text>&amp;nbsp;By Frank Prengel (Microsoft Blog) 

&lt;p&gt;&lt;/p&gt;
&lt;table cellSpacing=0 cellPadding=0 width="100%"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;p&gt;Some time ago I &lt;a title="Link to another page in this blog" href="http://blogs.msdn.com/frankpr/archive/2004/02/24/79463.aspx" target=Bwindow&gt;wrote about a new feature &lt;/a&gt;that's coming in VS 2005: projects that contain source files in different languages (C++, C#, VB.NET, ...), which are combined into a single assembly. (That is really new &amp;amp; exciting because today you can only combine different language &lt;em&gt;projects&lt;/em&gt; in a common &lt;em&gt;solution&lt;/em&gt; - which still gives separate assemblies from each project which have to be linked together &lt;em&gt;dynamically&lt;/em&gt;).&lt;/p&gt;

&lt;p&gt;Well, recently I looked into this again after Beta 1 became available, and I have to qualify my earlier statement a little bit, although the main message still stands and continues to excite me :-)&lt;/p&gt;
&lt;p&gt;So what's up with this? The fact is: thanks to custom build steps, MSIL linking (the ability to &lt;em&gt;statically&lt;/em&gt; link netmodules into one assembly), and other cool features of the new C++ compiler in Whidbey, you can add C# and VB.NET (and other) source files to a .NET C++ project, and &lt;em&gt;build everything together into a single EXE or DLL&lt;/em&gt;. Cool, eh?&lt;/p&gt;

&lt;p&gt;OK, so if this is old hat to you, &lt;a title="Link outside of this blog" href="http://www.kommandozeile.de/" target=Bwindow&gt;go somewhere else&lt;/a&gt;, otherwise read on, if you want to find out how it works. I've made a quick &amp;amp; dirty sample (nothing polished, just POC), which I'll describe below:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Create a WinForms C++ project in VS 2005.&lt;/li&gt;
&lt;li&gt;Create a C# class file using the editor of your choice (you can't directly add one to a C++ project...), and copy that into the project directory (windows explorer ...), then include it into the project (IDE). Looks like this: &lt;br /&gt;&lt;img src="http://www.frankpr.net/whidbey/proj.jpg"&gt; &lt;/li&gt;

&lt;li&gt;Then right-click on the class file in solution explorer, select "Properties", and create a custom build step for this file: &lt;br /&gt;&lt;img src="http://www.frankpr.net/whidbey/classprop.jpg"&gt;&lt;br &amp;gt=""&gt;(Obviously we have to bring the C# compiler in here somehow - during build, the C++ won't know what to do with a C# source file... :-). We create a netmodule here, so this can be IL linked into the final EXE.&lt;/li&gt;
&lt;li&gt;Open the project properties and add the netmodule that is created from the C# class as input to the C++ linker: &lt;br /&gt;&lt;img src="http://www.frankpr.net/whidbey/linker.jpg"&gt; &lt;/li&gt;
&lt;li&gt;Now add a "#using" directive to the Form.h: &lt;br /&gt;&lt;img src="http://www.frankpr.net/whidbey/using.jpg"&gt; &lt;/li&gt;

&lt;li&gt;And that's it: you can now reference the C# class in the C++ editor, even IntelliSense is working: &lt;br /&gt;&lt;img src="http://www.frankpr.net/whidbey/intelli.jpg"&gt; &lt;/li&gt;
&lt;li&gt;Build the project, and run it. &lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;The cool thing is that you have no dependency on the netmodule - it has been compiled into the EXE, which is all you would have to deploy.&lt;/p&gt;
&lt;p&gt;You can download my sample &lt;a title="Link outside of this blog" href="http://www.frankpr.net/whidbey/multlangtest.zip" target=Bwindow&gt;here&lt;/a&gt;.&lt;/p&gt;&lt;/td&gt;&lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;img src ="http://flounder_aaeng/blogs/devnotes/aggbug/234.aspx" width = "1" height = "1" /&gt;</text>
  <last_update>2007-10-04T00:51:49.0670806Z</last_update>
  <source_title />
  <source_link />
  <comments />
  <references />
  <attachments />
</Content>